package com.ruoyi.ai.service.impl;

import com.ruoyi.ai.service.ChatService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

@Service
public class ChatServiceImpl implements ChatService {

    private final ChatClient chatClient;

    public ChatServiceImpl(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @Override
    public String chat(String msg) {
        return chatClient.prompt()
                .user(msg)
                .call()
                .content();
    }


    @Override
    public Flux<String> chatStream(String msg) {
        return chatClient.prompt()
                .user(msg)
                .stream()
                .content();
    }

}
